﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace XmlDSigEx
{
    public abstract class SignatureProvider:ISignatureProvider
    {
        public abstract bool CanHandle(System.Xml.XmlElement signatureElement);

        public abstract ISignatureAlgorithm GetSignatureAlgorithm(System.Xml.XmlElement signatureElement);

        protected string GetAlgorithm(XmlElement signatureElement)
        {
            XmlNamespaceManager manager = new XmlNamespaceManager(signatureElement.OwnerDocument.NameTable);
            manager.AddNamespace("ds", XmlSigner.NS_XMLDSIG);
            return signatureElement.SelectSingleNode("./ds:SignedInfo/ds:SignatureMethod/@Algorithm", manager).Value;
        }
    }
}
